﻿using System;
using System.Windows.Data;
using System.Windows.Media;

namespace AnthStat.WPF.Applications.Converters
{
    public sealed class ChildSelectedBackgroundConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // TODO: Code contracts

            bool isSelected = (bool)value;
            Color paramColor = (Color)parameter;

            Color highlightColor = Color.FromRgb(paramColor.R, paramColor.G, paramColor.B);

            if (isSelected == false)
            {
                Brush background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                return background;
            }
            else
            {
                Brush background = new SolidColorBrush(highlightColor);
                return background;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
